﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyMusicPlay._4._0
{
    public static class DictionaryExtend
    {

        public static int GetMusicIndex(this Dictionary<int, Music> list, Music music)
        {
            for (int i = 0; i < list.Count; i++)
            {
                if (music.Name == list[i].Name && music.Singer == list[i].Singer)
                {
                    return i;
                }
            }
            return 0;
        }

        public static List<T> ToLists<J, T>(this Dictionary<J, T> dict)
        {
            List<T> list = new List<T>();
            foreach (var item in dict)
            {
                list.Add(item.Value);
            }
            return list;
        }

        public static List<J> ToListsByKey<J, T>(this Dictionary<J, T> dict)
        {
            List<J> list = new List<J>();
            foreach (var item in dict)
            {
                list.Add(item.Key);
            }
            return list;
        }
    }
}
